package com.staryy.activiti7_workflow;

import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.io.InputStream;
import java.util.List;
import java.util.zip.ZipInputStream;


/**
 * 流程发布
 */
@SpringBootTest
public class Part1_Deployment {

    @Autowired
    private RepositoryService repositoryService;

    @Test
    public void initDeploymentBPMN(){
        String filePath = "BPMN/QingJia001.bpmn";
        Deployment deploy = repositoryService.createDeployment()
                .addClasspathResource(filePath)
                .name("请假流程1")
                .deploy();

        System.out.println(deploy.getName());
    }

    @Test
    public void initDeploymentZip(){
        String zipPath = "";
        InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(zipPath);
        ZipInputStream zipInputStream = new ZipInputStream(inputStream);
        repositoryService.createDeployment()
                .addZipInputStream(zipInputStream)
                .name("压缩发布流程").deploy();
    }

    @Test
    public void getDeploys(){
        List<Deployment> list = repositoryService.createDeploymentQuery().list();
    }
}
